home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Collections: Panorama
/
Panorama - Disk 29B (1988-05-11)(Pacific North-West Amigas Club)[WB].zip
/
Panorama - Disk 29B (1988-05-11)(Pacific North-West Amigas Club)[WB].adf
/
BOARD.GAMES
/
chain reaction
(
.txt
)
< prev
next >
Wrap
AmigaBASIC Source Code
|
1987-08-15
|
7KB
|
194 lines
PRINT "Select square using arrow keys..."
PRINT " Place bombs with the space bar."
PRINT " When critical mass for a given"
PRINT " square is reached, the chain "
PRINT " reaction will commence."
FOR i=1 TO 10000:NEXT i
DEFINT a-z:DEFSNG r,g,b
SCREEN 1,320,200,3,1:WINDOW 3,"",(0,0)-(311,186),16,1:WINDOW OUTPUT 3:COLOR 3,0
DIM s(42,1),u(4,5),p(4,5),j(4,5),bx(4,5),by(4,5),n(1,5),er(528),w1(255),w2(255),rt(30),tr(30),tx(30),ty(30)
FOR i=0 TO 255 : w1(i)=RND*255-128:w2(i)=RND*255-128:NEXT
RESTORE palettedata:FOR i = 0 TO 7:READ r,g,b:PALETTE i,r,g,b:NEXT
palettedata:
DATA 0,0,.7,0,0,0,.8,.8,0,.7,.7,.7,.33,.87,0,.9,.9,.9,.6,0,0,0,.6,0
WIDTH 40:CLS:RANDOMIZE TIMER
GOSUB initshapes:e=0
FOR i=1 TO 3: FOR j=1 TO 4:j(i,j)=4:NEXT:j(i,0)=3:j(i,5)=3:NEXT
RESTORE corners: FOR j=1 TO 4:j(0,j)=3:j(4,j)=3:READ a,b:j(a,b)=2:NEXT
corners:DATA 0,0,0,5,4,0,4,5
RESTORE Bombpos:FOR i=1 TO 4:FOR j=1 TO i:READ bx(i,j),by(i,j):NEXT j,i
bx(4,5)=bx(4,4):by(4,5)=by(4,4)
Bombpos: DATA 13,9,6,9,20,9,13,5,4,15,22,15,13,3,13,17,4,9,22,9
LOCATE 8,14:PRINT "CHAIN REACTION"
LOCATE 12,9:PRINT "Number of players(1/2)?";
WHILE np<>1 AND np<>2:np=VAL(INKEY$):WEND
IF np<>2 THEN
LOCATE 16,10:PRINT "Computer first (Y/N)?";
WHILE k$ <>"Y" AND k$<>"N":k$=UCASE$ (INKEY$):WEND
tu=ABS(k$="Y")
END IF
CLS:COLOR 3,1:LOCATE 1,13:PRINT " CHAIN REACTION "
GOSUB drawgrid
MainLoop:
WHILE e=0:tu=-tu+1:co=tu+6
IF np=1 AND tu=0 THEN
GOSUB computer
ELSE
GOSUB human
WHILE p(y,x)<>tu+1 AND p(y,x):GOSUB human:WEND
END IF
u(y,x)=u(y,x)+1:fs(tu)=fs(tu)+1:IF p(y,x)=0 THEN p(y,x)=tu+1
GOSUB placebomb
IF u(y,x)=j(y,x) THEN
checkgrid:e=0:fg=0:FOR p=0 TO 4:FOR q=0 TO 5:y=p:x=q
IF u(y,x)>=j(y,x) AND e=0 THEN fg=1:GOSUB fullsquare
NEXT q,p:IF fg=1 AND e=0 THEN checkgrid
END IF
WEND
endgame:
COLOR 3,1:LOCATE 24,15:PRINT " GAME OVER ";:FOR i=1 TO 10000:NEXT
LOCATE 24,5:PRINT " Press space bar to play again. ";
k$="":WHILE k$<>" ":k$=INKEY$:WEND
SCREEN CLOSE 3:WINDOW CLOSE 3: RUN
human:
WHILE INKEY$<>"":WEND:x=hx(tu):y=hy(tu):dx=0:dy=0:GOSUB drawcursor:k$=""
WHILE k$<>" ":k$=INKEY$
IF k$=CHR$(28) THEN IF y>0 THEN dy=-1
IF k$=CHR$(29) THEN IF y<4 THEN dy=1
IF k$=CHR$(31) THEN IF x>0 THEN dx=-1
IF k$=CHR$(30) THEN IF x<5 THEN dx=1
IF dx<>0 OR dy<>0 THEN
co=0:GOSUB drawcursor
x=x+dx:y=y+dy:co=tu+6:GOSUB drawcursor
dx=0:dy=0
END IF
WEND:hx(tu)=x:hy(tu)=y
co=0:GOSUB drawcursor:co=tu+6:RETURN
fullsquare:
r=0:yy=32*y+15:xx=36*x+50:WAVE 0,w1:WAVE 1,w2
FOR i=1 TO 4:PUT(xx+2,yy+2),er,PSET
FOR j=1 TO 4:n(1,j)=INT(RND*3)-1:NEXT
r=-r+1:k=u(y,x)+1:bn=co-6:IF k=6 THEN k=5
ON k GOSUB b0,b1,b2,b3,b4,b4,
FOR m=255 TO 10 STEP -20:SOUND 100,0.1,m,0
SOUND 100,0.1,m,3:FOR n=1 TO RND*20:NEXT n,m:NEXT
tx=x:ty=y:j1=0:k1=k-1:y1=32*y+15+by(1,1):x1=36*x+50+bx(1,1)
IF tx>0 THEN x=tx-1:dx=-1:dy=0:GOSUB explodebombs:GOSUB addbomb
IF tx<5 THEN x=tx+1:dx=1:dy=0:GOSUB explodebombs:GOSUB addbomb
x=tx:IF ty>0 THEN y=ty-1:dy=-1:dx=0:GOSUB explodebombs:GOSUB addbomb
IF ty<4 THEN y=ty+1:dy=1:dx=0:GOSUB explodebombs: GOSUB addbomb
IF fs(0)<1 OR fs(1)<1 THEN e=1
y=ty:u(y,x)=u(y,x)-j(y,x):GOSUB placebomb:IF u(y,x)=0 THEN p(y,x)=0
RETURN
addbomb:
IF p(y,x)<>tu+1 THEN fs(tu)=fs(tu)+u(y,x):fs(-tu+1)=fs(-tu+1)-u(y,x)
p(y,x)=tu+1:u(y,x)=u(y,x)+1:GOSUB placebomb:RETURN
drawgrid:
FOR y=0 TO 4:yy=32*y+16:FOR x=0 TO 5:xx=36*x+51
LINE(xx,yy)-(xx+34,yy+30),2,b
NEXT x,y
GET(xx+1,yy+1)-(xx+33,yy+29),er:
RETURN
drawcursor:
yy=32*y+15:xx=36*x+50
LINE(xx,yy)-(xx+36,yy+32),co,b
LINE(xx+2,yy+2)-(xx+34,yy+30),co,b
RETURN
placebomb:
yy=32*y+15:xx=36*x+50:r=0:bn=co-6
PUT(xx+2,yy+2),er,PSET:k=u(y,x)+1:IF k=6 THEN k=5
ON k GOTO b0,b1,b2,b3,b4,b4
b0:RETURN
b1:PUT(xx+bx(1,k-1),yy+by(1,k-1)),s(0,bn):RETURN
b2:FOR j=1 TO k-1:PUT(xx+bx(2,j)+n(r,j),yy+by(2,j)+n(r,j)),s(0,bn):NEXT:RETURN
b3:FOR j=1 TO k-1:PUT(xx+bx(3,j)+n(r,j),yy+by(3,j)+n(r,j)),s(0,bn):NEXT:RETURN
b4:FOR j=1 TO k-1:PUT(xx+bx(4,j)+n(r,j),yy+by(4,j)+n(r,j)),s(0,bn):NEXT:RETURN
checkneighbour:
fp=1:IF y>0 THEN IF p(y-1,x)=2 THEN ay=y-1:RETURN
IF x>0 THEN IF p(y,x-1)=2 THEN ax=x-1:RETURN
IF x<5 THEN IF p(y,x+1)=2 THEN ax=x+1:RETURN
IF y<4 THEN IF p(y+1,x)=2 THEN ay=y+1:RETURN
fp=0:RETURN
computer:
xt=0:FOR y=0 TO 4:FOR x=0 TO 5
IF p(y,x)<>2 THEN xt=xt+1:ty(xt)=y:tx(xt)=x
NEXT x,y
LOCATE 24,15:COLOR 3,0:PRINT "thinks...hmm";
FOR i=1 TO xt:rt(i)=0:tr(i)=0:y=ty(i):x=tx(i):GOSUB checkneighbour
IF fg=1 AND fp AND u(y,x)>0 THEN endcomputer
IF u(y,x)+1=j(y,x) THEN
IF fp=1 AND u(ay,ax)+1=j(ay,ax) THEN rt(i)=6:GOTO checknext
IF fp=1 THEN rt(i)=2:GOTO checknext
IF fp=0 THEN rt(i)=1:GOTO checknext
END IF
IF j(y,x)=2 THEN
IF fp=0 AND u(y,x)=1 THEN rt(i)=1:GOTO checknext
IF fp=0 AND u(y,x)=0 THEN rt(i)=4:GOTO checknext
IF fp=1 AND u(y,x)=1 THEN rt(i)=4:GOTO checknext
END IF
IF u(ay,ax)+1=j(ay,ax) THEN rt(i)=1:GOTO checknext
IF u(y,x)+2>=j(y,x) THEN
IF fp=1 AND u(ay,ax)+1<j(ay,ax) THEN rt(i)=5:GOTO checknext
IF fp=0 THEN rt(i)=3:GOTO checknext
rt(i)=2:GOTO checknext
END IF
IF fp=0 THEN rt(i)=2:GOTO checknext
rt(i)=1
checknext:
NEXT:zt=0:ab=6
WHILE zt=0
FOR i=1 TO xt: IF rt(i)=ab THEN zt=zt+1:tr(zt)=i
NEXT:ab=ab-1
WEND
dh=INT(zt*RND)+1:hd=tr(dh):y=ty(hd):x=tx(hd)
endcomputer:
LOCATE 24,15:PRINT " ";:fg=fg+1:RETURN
explodebombs:
j1=j1+1:xx=x1-bx(1,1):yy=y1-by(1,1):s=1087:bn=co-6
WAVE 0,SIN:SOUND 660,0.5,255
FOR j=1 TO 500:NEXT:SOUND 0,0,0
PUT (xx+bx(k1,j1)+n(r,j1),yy+by(k1,j1)+n(r,j1)),s(0,bn)
IF dy=0 THEN
x2=x1+35*dx:dx=dx*4:PUT(x1,y1),s(0,bn)
FOR i=x1 TO x2 STEP dx:s=s-40:SOUND s,1,50
PUT (i,y1),s(0,bn):PUT(i+dx,y1),s(0,bn):NEXT
PUT (xx+3,yy+3),er
ELSE
y2=y1+31*dy:dy=dy*4:PUT(x1,y1),s(0,bn)
FOR i=y1 TO y2 STEP dy:s=s-40:SOUND s,1,50
PUT (x1,i),s(0,bn):PUT(x1,i+dy),s(0,bn):NEXT
PUT(xx+3,yy+3),er
END IF
RETURN
initshapes:
RESTORE redbomb
FOR j=0 TO 1:FOR i=0 TO 42
READ a$:s(i,j)=VAL("&H" +a$):NEXT i,j:RETURN
redbomb:
DATA B,D,3,200,400,400,0,1800,3000,1B00,A00,400,A00,1B00,0,0
DATA 0,0,0,E00,2780,4FC0,E4E0,F5E0,FBE0,F5E0,64C0,3F80,E00,200,400,400
DATA E00,3F80,7FC0,E4E0,F5E0,FBE0,F5E0,64C0,3F80,E00,3F80
greenbomb:
DATA B,D,3,200,400,400,E00,3F80,7FC0,FFE0,FFE0,FFE0,FFE0,7FC0,3F80,E00,
DATA 0,0,0,E00,2780,4FC0,E4E0,F5E0,FBE0,F5E0,64C0,3F80,E00,200,400,400
DATA E00,3F80,7FC0,E4E0,F5E0,FBE0,F5E0,64C0,3F80,E00,3F80